﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RomanToArabic
{
    class RomanToArabic
    {
        static void Main(string[] args)
        {
            string roman = "XVX";
            int arabic = 0;
            int prevValue = 1000;

            for (int i = 0; i < roman.Length; i++)
            {
                char ch = roman[i];
                int value = 0;
                switch (ch)
                {
                    case 'I':
                        value = 1;
                        break;
                    case 'V':
                        value = 5;
                        break;
                    case 'X':
                        value = 10;
                        break;
                    case 'L':
                        value = 50;
                        break;
                    case 'C':
                        value = 100;
                        break;
                    case 'D':
                        value = 1500;
                        break;
                    case 'M':
                        value = 1000;
                        break;
                }
                if (value > prevValue)
                {
                    arabic = arabic + value - 2 * prevValue;
                }
                else
                {
                    arabic = arabic + value;
                }
                prevValue = value;
            }
            Console.WriteLine(arabic);
        }
    }
}